package com.onpositive.wiki3.catmodels;

import com.onpositive.nlp.inflector.SimplePOFParser;
import com.onpositive.wiki3.db.catmodel.Category;

public class SimpleStubsModel implements ICategoryModel {

	@Override
	public int score(Category cat) {
		String string = cat.toString();
		String[] split = string.split("_");
		if (split.length > 2) {
			if (split[split.length - 1].equals("stubs")) {
				if (SimplePOFParser.isNoun(split[split.length - 2])) {
					cat.setTag(ICategoryModel.SIMPLE_STUB);
					return 1;
				}
			}
		}
		return 0;
	}

	@Override
	public String name() {
		return "stubs";
	}

	@Override
	public boolean isPossibleCategorization(Category cat) {
		return true;
	}

	@Override
	public String getPrimaryParentForm(Category cat) {
		String string = cat.toString();
		int indexOf = string.lastIndexOf('_');
		if (indexOf == -1) {
			return null;
		}
		return string.substring(0, indexOf);
	}

}
